/**
 * 
 */
package com.wegax.naming;

import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author wegax
 *
 */
@Configuration
public class NamingServiceClientInjector {
	
	@Bean
	JaxWsProxyFactoryBean namingServiceFactory() {
		JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
		factory.setServiceClass(NamingService.class);
		factory.setAddress("http://localhost:8080/whats-your-name/Naming");
		//factory.setAddress("http://192.168.0.20:8080/whats-your-name/Naming");
		factory.getInInterceptors().add(new LoggingInInterceptor());
		factory.getOutInterceptors().add(new LoggingOutInterceptor());
		return factory;
	}
	
	@Bean
	public NamingService namingService() {
		return (NamingService) namingServiceFactory().create();
	}

}
